//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Globalization;
using System.Windows.Data;

namespace OpenLS.Spreadsheet
{
    public class PointsToPixelConverter: IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return ToPixel(System.Convert.ToDouble(value));
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return ToPoint(System.Convert.ToDouble(value));
        }

        #endregion
        public static PointsToPixelConverter Instance
        {
            get
            {
                return instance ;
            }
        }
        static PointsToPixelConverter instance = new PointsToPixelConverter();

        internal static double ToPixel(double value)
        {
            return value * 4 / 3;
        }
        internal static double ToPoint(double value)
        {
            return value * 3 / 4;
        }
    }
}
